package com.ruoyi.web.controller.websocket;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.teaching.domain.vo.ChatMessageVO;
import com.ruoyi.teaching.service.WebSocketMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李志鑫
 * @since 2024-08-23
 */
@RestController
@RequestMapping("/webSocketMessage")
@Api(tags = "webSocket-聊天记录")
public class WebSocketMessageController {

    @Autowired
    private WebSocketMessageService webSocketMessageService;

    @GetMapping("/selectChatMessage")
    @ApiOperation(value = "查询聊天记录", notes = "查询聊天记录根据聊天id")
    public AjaxResult selectAppliedUser(Integer pageNum, Integer pageSize, Long dialogueId,String message) {
        return webSocketMessageService.selectChatMessage(pageNum,pageSize,dialogueId,message);
    }

    @PostMapping("/insertChatMessage")
    @ApiOperation(value = "添加聊天记录", notes = "添加聊天记录")
    public AjaxResult insertChatMessage(@RequestBody ChatMessageVO chatMessageVO) {
//        添加公告
        System.out.println(chatMessageVO);
        return webSocketMessageService.insertChatMessage(chatMessageVO);
    }

    @PostMapping("/deleteChatMessage")
    @ApiOperation(value = "删除对话", notes = "对话框id")
    public AjaxResult deleteChatMessage(Long dialogueId) {
        return webSocketMessageService.deleteChatMessage(dialogueId);
    }
}

